**
 * 系统管理 用户管理
 */
<template>
  <div style="width:800px;margin-left:300px;margin-top:40px">
    <!-- 搜索筛选 -->
    <!-- <el-form :inline="true" class="user-search" :model="formInline">
      <el-form-item label="搜索："> </el-form-item>
      <el-form-item label="">
        <el-input
          size="small"
          v-model="formInline.kw"
          placeholder="输入用户账号"
        ></el-input>
      </el-form-item>
      <el-form-item>
        <el-button
          size="small"
          type="primary"
          icon="el-icon-search"
          @click="search"
          >搜索</el-button
        >
      </el-form-item>
    </el-form> -->
    <!--列表-->
    <el-table
      size="small"
      @selection-change="selectChange"
      :data="userData"
      highlight-current-row
      v-loading="loading"
      border
      element-loading-text="拼命加载中"
      style="width: 100%"
    >
      <el-table-column
        align="center"
        prop="nickname"
        label="用户名"
        width="150"
      >
      </el-table-column>
      <el-table-column
        align="center"
        prop="nickname"
        label="头像"
        width="80"
      >
      <template slot-scope="scope">
          <div>
            <el-image
              style="width: 40px; height: 40px;"
              :src="'http://chm.pengdong.top/index/get/'+scope.row.avatar"
              fit="scale-down"
            ></el-image>
          </div>
        </template>

      </el-table-column>
      <el-table-column
        align="center"
        prop="follow.followUserAccount"
        label="账号"
        width="150"
      >
      </el-table-column>

      <el-table-column
        align="center"
        prop="follow.createDate"
        label="关注时间"
        min-width="200"
      >
        <template slot-scope="scope">
          <div>{{ scope.row.follow.createDate }}</div>
        </template>
      </el-table-column>

      <el-table-column label="操作" min-width="200" align="center">
        <template slot-scope="scope">
          <div>
            <el-button
              size="mini"
              type="danger"
              style="color:white"
              @click="deleteUser(scope.$index, scope.row)"
              >取消关注</el-button
            >
          </div>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页组件 -->
    <!-- <Pagination
      v-bind:child-msg="pageparm"
      @callFather="callFather"
    ></Pagination> -->
  </div>
</template>

<script>
import Pagination from "../../components/common/Pagination.vue";
import { listFocusAuthor,unFocus} from "@/api/article.js";
export default {
  data() {
    return {
      loading: false, //是显示加载
      //用户数据
      userData: [],
    };
  },
  // 注册组件
  components: {
    Pagination,
  },

  /**
   * 数据发生改变
   */
  watch: {},

  /**
   * 创建完毕
   */
  created() {
    this.getdata();
  },

  methods: {
    // 获取数据方法
    getdata() {
      listFocusAuthor().then((res) => {
        var vo = res.data;
        if (vo.code == 10000) {
          this.userData = res.data.data;
          console.log(this.userData);
        } else {
          console.log("no");
        }
      });
    },

    // // 分页插件事件
    // callFather(parm) {
    //   this.formInline.page = parm.currentPage;
    //   this.formInline.limit = parm.pageSize;
    //   this.getdata(this.formInline);
    // },
    //搜索事件
    // search() {
    //   this.getdata1(this.formInline);
    // },
  

    // 删除用户
    deleteUser(index, row) {
      this.$confirm("确定要取关吗?", "信息", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.loading = true;
          // 删除
          unFocus(row.follow.userAccount,row.follow.followUserAccount).then((res) => {
            this.loading = false;
            if (res.data.code == 10000) {
              this.$message({
                type: "success",
                message: "取关成功",
              });
              this.getdata();
            } else {
            }
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消操作！",
          });
        });
    },
  },
};
</script>

<style scoped>
.user-search {
  margin-top: 20px;
}
.userRole {
  width: 100%;
}
</style>

 